package com.inno.auth.domain.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.inno.auth.domain.entity.MemberBO;
import com.inno.auth.domain.service.MemberDomainService;
import com.inno.auth.infra.basic.entity.PlannerMember;
import com.inno.auth.infra.basic.service.PlannerMemberService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class MemberDomainServiceImpl implements MemberDomainService {
    @Resource
    private PlannerMemberService plannerMemberService;

    /**
     * 系统赠送会员  内部使用接口
     * @param memberBO
     */
    @Override
    public void gifts(MemberBO memberBO) {
        PlannerMember plannerMember = convertBOToEntity(memberBO);
        plannerMember.setId(IdUtil.getSnowflakeNextId());
        plannerMemberService.insert(plannerMember);
    }

    private static PlannerMember convertBOToEntity(MemberBO memberBO){
        PlannerMember plannerMember = new PlannerMember();
        BeanUtil.copyProperties(memberBO,plannerMember);
        return plannerMember;
    }
}
